/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: dings
 * Date: 2024-07-09
 * Time: 11:38
 */
public class Test {
    public void addIndex(int index, int data) {
        int len = size();
        if(index < 0 || index > len) {
            return;
        }
        if(index == 0) {
            addFirst(data);
            return;
        }
        if(index == len) {
            addLast(data);
            return;
        }
        ListNode cur = head;
        ListNode node = new ListNode(33);
        for (int i = 0; i < index; i++) {
            cur = cur.next;
        }

        node.next = cur;
        node.prev = cur.prev;
        cur.prev.next = node;
        cur.prev = node;
    }
    public static void main(String[] args) {

    }
}
